#!/bin/bash
#===============================================================================
# Copyright 2011 zod.yslin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
# Author: zod.yslin
# Email: 
# File Name: demo.sh
# Description: 
#   Arithmetic expansion allows the evaluation of an arithmetic expression and the substitution of the result. 
#       $(( expression ))
#   See the let and declare builtin commands and Arithmetic Expansion
#   The shell allows arithmetic expressions to be evaluated, as one of the shell expansions or by the let and the -i option to the declare builtins
#   id++ id--
#       variable post-increment and post-decrement 
#   ++id --id
#       variable pre-increment and pre-decrement 
#   - +
#       unary minus and plus 
#   ! ~
#       logical and bitwise negation 
#   **
#       exponentiation 
#   * / %
#       multiplication, division, remainder 
#   + -
#       addition, subtraction 
#   << >>
#       left and right bitwise shifts 
#   <= >= < >
#       comparison 
#   == !=
#       equality and inequality 
#   &
#       bitwise AND 
#   ^
#       bitwise exclusive OR 
#   |
#       bitwise OR 
#   &&
#       logical AND 
#   ||
#       logical OR 
#   expr ? expr : expr
#       conditional operator 
#   = *= /= %= += -= <<= >>= &= ^= |=
#       assignment 
#   expr1 , expr2
#       comma
# Edit History: 
#   2011-10-04    File created.
#===============================================================================
a=1
b=4
echo $((a+b))
echo $((a&b))
echo $((~a))
echo $((!a))
echo $((a))
a=`expr $a + 1`
echo $a
a=$((a+1))
echo $a
let a++
echo $a
declare -i a=++a
echo $a
